﻿using AutoMapper;
using MediatR;
using PersonnelManagement.Application.Command.ClientCommand;
using PersonnelManagement.Application.Command.ManpowerCommand;
using PersonnelManagement.Domain.PersonnelDomain;
using PersonnelManagement.Infrstructre.Interface;

namespace PersonnelManagement.Application.CommandHandler.ClientCommandHandlers
{
    public class ClientAddCommandHandlers : IRequestHandler<ClientAddCommand, int>
    {
        IClientRepository mRep;
        IMapper mapper;

        public ClientAddCommandHandlers(IClientRepository mRep, IMapper mapper)
        {
            this.mRep = mRep;
            this.mapper = mapper;
        }
        public async Task<int> Handle(ClientAddCommand request, CancellationToken cancellationToken)
        {
            return await mRep.Add(mapper.Map<Client>(request.AddDtos));
        }
    }
}
